package com.wxzz.elearing.evaluation.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wxzz.elearing.evaluation.entity.BusinessCategoryRule;
import com.wxzz.elearing.evaluation.entity.WxUserBusinessCategoryGroup;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Optional;

/**
 * <p>
 * 工厂体检/星级认证 Mapper 接口
 * </p>
 *
 * @author
 * @since 2021-04-10
 */
public interface BusinessCategoryRuleMapper extends BaseMapper<BusinessCategoryRule> {

    @Select("SELECT\n" +
            "\twubcg.* \n" +
            "FROM\n" +
            "\tbusiness_category_rule_group bcrg\n" +
            "\tJOIN wx_user_business_category_group wubcg ON bcrg.id = wubcg.common_id \n" +
            "WHERE\n" +
            "\tbcrg.business_category_rule_id = #{businessCategoryRuleId} \n" +
            "\tAND wubcg.wx_user_id = #{wxUserId} \n" +
            "\tAND bcrg.deleted = 0 \n" +
            "\tAND wubcg.exam_status = 0" +
            "\tAND wubcg.deleted = 0")
    List<WxUserBusinessCategoryGroup> selectBusinessCategoryRule4startId(@Param("wxUserId")Long wxUserId, @Param("businessCategoryRuleId")Long businessCategoryRuleId);

}
